home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Mac OS SDK / Dev.CD Jan 98 SDK2.toast / Development Kits (Disc 2) / QuickDraw GX / Programming Stuff / GX Libraries / GraphicsToolboxLibrary.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-31  |  1.6 KB  |  64 lines  |  [TEXT/MPS ]

  1.  
  2. /*
  3.     File:        GraphicsToolboxLibrary.c
  4.  
  5.     Contains:    graphics libraries - graphics toolbox routines 
  6.  
  7.     Written by:    Cary Clark, Georgiann Delaney, Michael Fairman, Dave Good, Robert Johnson, Keith McGreggor, Mike Reed, Oliver Steele, David Van Brink, Chris Yerga
  8.  
  9.     Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  10.  
  11.     Change History (most recent first):
  12.  
  13.          <1>      1/9/95    JD        First checked in.
  14. */
  15.  
  16. #include <Memory.h>
  17. #include <Resources.h>
  18. #include <GXFonts.h>
  19. #include "GraphicsToolboxLibrary.h"
  20.  
  21. /* jtdfix - is this file needed?? */
  22. #define segmentLoaderTrashesResLoadState
  23.  
  24. #ifdef segmentLoaderTrashesResLoadState
  25.     #define SETRESLOAD(load)    SetResLoad(load)
  26. #else
  27.     #define SETRESLOAD(load)
  28. #endif
  29.  
  30. long AddResFileFonts(short resFileID, gxFont** fonts)
  31. {
  32.     long i, count;
  33.     long validFonts = 0;
  34.     char resLoadState = *(char*)0xa5e;
  35.     short oldResFile = CurResFile();
  36.  
  37.     UseResFile(resFileID);
  38.     count = Count1Resources('sfnt');
  39.     if (fonts)
  40.         SetHandleSize((Handle)fonts, count * sizeof(gxFont));
  41.     SetResLoad(false);
  42.  
  43.     for (i = 1; i <= count; i++)
  44.     {   Handle sfnt;
  45.  
  46.         SETRESLOAD(false);
  47.         sfnt = Get1IndResource('sfnt', i);
  48.         if (sfnt && !ResError())
  49.         {   gxFont fontID = GXNewFont(gxResourceFontStorage, sfnt, 0);
  50.             if (fonts)
  51.                 (*fonts)[validFonts] = fontID;
  52.             validFonts++;
  53.         }
  54.     }
  55.  
  56.     SetResLoad(resLoadState);
  57.     if (fonts && validFonts != count)
  58.         SetHandleSize((Handle)fonts, validFonts * sizeof(gxFont));
  59.     UseResFile(oldResFile);
  60.  
  61.     return validFonts;
  62. }
  63.  
  64.